#include "stdafx.h"
#include "SymbolAdapter.h"
#include "base/util/string_number_conversions.h"

SymbolAdapter::SymbolAdapter() {
    m_colNames.push_back(L"lb_code");
    m_colNames.push_back(L"lb_name");
}

SymbolAdapter::~SymbolAdapter() {

}
int SymbolAdapter::getCount() {
    return m_goodsList.size();
}

void SymbolAdapter::getView(int position, SOUI::SWindow *pItem, pugi::xml_node xmlTemplate) {
    if (pItem->GetChildrenCount() == 0) {
        pItem->InitFromXml(xmlTemplate);
    }
    
    if (position >= (int)m_goodsList.size()) {
        return;
    }
    
    auto pGoods = m_goodsList[position];
    if (pGoods) {
        pItem->FindChildByName(L"lb_code")->SetWindowText(pGoods->getStrCode());
        pItem->FindChildByName(L"lb_name")->SetWindowText(pGoods->getName());
    }
}

SOUI::SStringW SymbolAdapter::GetColumnName(int iCol) const {
    if (iCol < (int)m_colNames.size()) {
        return m_colNames[iCol];
    }
    return L"";
}



std::vector<SOUI::SStringW> SymbolAdapter::GetColumnNames() {
    return m_colNames;
}

void SymbolAdapter::setColumnNames(const std::vector<SOUI::SStringW> &names) {
    m_colNames = names;
}
